package com.example.tome.module_base.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @Created by TOME .
 * @时间 2018/5/2 17:17
 * @描述 ${TODO}
 */

public abstract class BaseCommonActivity extends AppCompatActivity {

    private Unbinder unBinder;
    public BaseCommonActivity mActivity ;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        unBinder = ButterKnife.bind(this);
        mActivity = this ;
        onViewCreated();
        CommonApplication.getApplication().getActivityControl().addActivity(this);
        initEventAndData();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        CommonApplication.getApplication().getActivityControl().removeActivity(this);
        unBinder.unbind();
    }

    protected void onViewCreated(){

    };

    /**
     * 获取当前Activity的UI布局
     *
     * @return 布局id
     */
    protected abstract int getLayoutId();

    /**
     * 初始化数据
     */
    protected abstract void initEventAndData();
}
